package j03zuoye;

import java.util.Random;

public class Circle {
    Point center;
    int r;

    public Circle() {
    }

    public Circle(Point center, int r) {
        this.center = center;
        this.r = r;
    }

    public double perimeter(){
        return 3.14*2*r;
    }
    public double area(){
        return 3.14*r*r;
    }

    //判断点是否在圆内
    public boolean containsPoint(Point p){
        //两点之间的距离
        double dis = center.distanceTo(p);
        //距离小于半径，园内
        return dis<r;
    }
    public boolean isIntersect(Circle c){
        //求圆心之间的距离
        double dis = center.distanceTo(c.center);
        //距离小于半径之和，相交
        return dis < r + c.r;
    }
}

class CircleTest{
    public static void main(String[] args) {
        Circle c1 = new Circle(
                //匿名对象
                new Point(0,0),
                4
        );
//        Point p2 = new Point(10,0);
        Point p2 = new Point(3,0);
//        Circle c2 = new Circle(p2,3);

//        System.out.println(4);
//        System.out.println(new Random());

        System.out.println(c1.containsPoint(p2));

        System.out.println("=========");
        Circle c2 = new Circle(
                new Point(10,0),
                7
        );
        System.out.println(c1.isIntersect(c2));
    }
}